<#include "config.ftl">
<#include "common_function.ftl">
<#assign base="/pi">
<#-- 页面统一基础模板 -->
<#macro page subtitle=macro_config.default_title body="" head="" setReferUrl=false referUrlKey="">
<#if setReferUrl><#if referUrlKey?has_content>${action.setReferUrl(referUrlKey)}<#else>${action.setReferUrl()}</#if></#if>
<#if navi?has_content>
	<#if title==macro_config.default_title>
		<#local title = navi?last>
	</#if>
</#if>
<html>
<head>
	<title>${macro_config.common_title}</title>
	<#list macro_config.css_path as css>
	<link href="${base}${css}" rel="stylesheet" type="text/css">
	</#list>
	<#list macro_config.js_path as js>
	<script language="javascript" src="${base}${js}"></script>
	</#list>
	<script>
	tree = new dhtmlXTreeObject("treeboxbox_tree", "100%", "100%", 0);
	 tree.enableTreeLines(true);
     tree.setImageArrays("plus", "plus2.gif", "plus3.gif", "plus4.gif", "plus.gif", "plus5.gif");
     tree.setImageArrays("minus", "minus2.gif", "minus3.gif", "minus4.gif", "minus.gif", "minus5.gif");
     tree.setStdImages("book.gif", "books_open.gif", "books_close.gif");
	
	tree.setSkin('dhx_skyblue');
	tree.setImagePath("../common/images/");
	tree.enableDragAndDrop(0);
	tree.enableTreeLines(false);
	tree.setImageArrays("plus", "", "", "", "plus.gif");
	tree.setImageArrays("minus", "", "", "", "minus.gif");
	tree.setStdImages("book.gif", "books_open.gif", "books_close.gif");
	tree.setXMLAutoLoading("tree.xml");
	tree.loadXML("tree.xml");
	</script>
	<meta http-equiv="Content-type" content="text/html; charset=${macro_config.charset}">
	${head}
</head>
<body ${body}>
<#nested>
</body>
</html>
</#macro>

<#-- 前台页面统一基础模板 -->
<#macro frontPage title=macro_config.default_title body="" head="" css="" js="" setReferUrl=false referUrlKey="">
<#if setReferUrl><#if referUrlKey?has_content>${action.setReferUrl(referUrlKey)}<#else>${action.setReferUrl()}</#if></#if>
<#if navi?has_content>
	<#if title==macro_config.default_title>
		<#local title = navi?last>
	</#if>
</#if>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>${macro_config.common_title} - ${title?html}</title>
	<link href="css/${css?html}.css" rel="stylesheet" type="text/css" />
	<script src="js/${js?html}.js" type="text/javascript"></script>
	<script src="js/common.js" type="text/javascript"></script>
	<script src="js/jquery-1.2.1.pack.js" type="text/javascript"></script>
    <script src="js/jquery-easing.1.2.pack.js" type="text/javascript"></script>
    <script src="js/jquery-easing-compatibility.1.2.pack.js" type="text/javascript"></script>
    <script src="js/coda-slider.1.1.1.pack.js" type="text/javascript"></script>
	<meta http-equiv="Content-type" content="text/html; charset=${macro_config.charset}">
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	${head}
</head>

<body ${body}>
<#nested>
</body>
</html>
</#macro>

<#--页面提示信息 -->
<#macro info>
<div class="info"><#nested></div>
</#macro>

<#--没有列表数据 -->
<#macro noData info="目前没有内容。">
<div class="info">${info}</div>
</#macro>

<#-- 后台导航、说明、功能链接设置 -->
<#macro intro navi=[] tasks={}>
<div id="navi"><#list navi as item><@p.menuMark/> ${item} </#list></div>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="explain">
<tr>
	<td><#nested></td>
</tr>
</table>
<#if (tasks?size > 0)>
<div style="margin-top:5px">
<#assign keys = tasks?keys>
<#list keys as key><a href="${parseLink(tasks[key])}" class="navlink">${key}</a> </#list>
</div>
</#if>
</#macro>

<#-- 设置表格奇偶行样式 -->
<#macro trClass>
<#if lineNumber?exists>
<#assign lineNumber=lineNumber+1/>
<#else>
<#assign lineNumber=1/>
</#if>
class="style${lineNumber%2}"
</#macro>
<#-- 表单必填项标识 -->
<#macro mustMark><span class="notNull">*</span></#macro>
<#-- 导航项间隔标识 -->
<#macro menuMark><span style="font-family:Webdings;color:#FF3300;font-weight:normal;">4</span></#macro>

<#-- 统计图表横向柱状图 -->
<#macro chartColumn width height="8" color="#0066CC"><span style="background:${color};height:${height};width:${width}"></span></#macro>

<#-- 表格鼠标覆盖后换色 -->
<#macro trChangeColor>
 onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"
</#macro>

<#-- 处理分页参数 -->
<#function getPageUrl pageNum>
<#local pageUrl=Request["URL"]>
<#if pageUrl?ends_with("?")>
<#return pageUrl + "pageSize=" + pageSize + "&pageNum=" + pageNum>
<#else>
<#return pageUrl + "&pageSize=" + pageSize + "&pageNum=" + pageNum>
</#if>
</#function>

<#-- 全部或分页显示 -->
<#function getPageUrlResize size>
<#local pageUrl=Request["URL"]>
<#if pageUrl?ends_with("?")>
<#return pageUrl + "pageNum=1&pageSize=" + size>
<#else>
<#return pageUrl + "&pageNum=1&pageSize=" + size>
</#if>
</#function>

<#-- 分页信息 -->
<#macro paging pagingList>
<#local pageCount=pagingList.pageCount>
<#local rowCount=pagingList.rowCount>
<#local pageNum=pagingList.pageNum>
<#local pageSize=pagingList.pageSize>
<#local maxPageSize=pagingList.maxPageSize>
<#local defaultPageSize=pagingList.defaultPageSize>
<#if rowCount == 0>
	<#if useFlag?exists>
	<div style="border:1px solid #666;padding:2 5 2 5;background:#efefef;color:#333">没有相关记录</div>
	<#else>
	<#assign useFlag = 1>
	</#if>
<#else>
<table>
<tr>
	<td style="line-height:150%">
	共 ${rowCount} 条记录 ${pageCount} 页 
	<#if pageCount gt 1 && pageSize!=maxPageSize>
		<span class="selectedPage" style="padding:2px 3px 0 3px"><a class="page" href="${getPageUrlResize(maxPageSize)}">全部显示</a></span>
	<#elseif pageSize==maxPageSize>
		<span class="selectedPage" style="padding:2px 3px 0 3px"><a class="page" href="${getPageUrlResize(defaultPageSize)}">分页显示</a></span>
	</#if>
	<#if (pageCount <= 11)>
		<#local startPage = 1>
		<#local endPage = pageCount>
	<#elseif (pageNum + 5 > pageCount)>
		<#local startPage = pageCount - 10>
		<#local endPage = pageCount>
	<#elseif (pageNum - 5 < 1)>
		<#local startPage = 1>
		<#local endPage = 11>
	<#else>
		<#local startPage = pageNum - 5>
		<#local endPage = pageNum + 5>
	</#if>
	<#if (pageCount > 1)>
		<#if (pageNum != 1)>
			<#if (pageCount > 11)>
				<a class="page" href="${getPageUrl(1)}" style="font-family:Webdings" title="首页">9</a>
			</#if>
			<a class="page" href="${getPageUrl(pageNum-1)}" style="font-family:Webdings" title="上页">3</a>
		<#else>
			<#if (pageCount > 11)>
				<span style="font-family:Webdings;color:#999">9</span>
			</#if>
			<span style="font-family:Webdings;color:#999">3</span>
		</#if>
		<#list startPage..endPage as x><#if x=pageNum>
			<span class="selectedPage">${x}</span>
	<#else>
		<span class="noSelectedPage"><a class="page" href="${getPageUrl(x)}">${x}</a></span>
	</#if>
	</#list>
		<#if (pageCount != pageNum)>
			<a class="page" href="${getPageUrl(pageNum+1)}" style="font-family:Webdings" title="下页">4</a>
			<#if (pageCount > 11)>
				<a class="page" href="${getPageUrl(pageCount)}" style="font-family:Webdings" title="尾页">:</a>
			</#if>
		<#else>
			<span style="font-family:Webdings;color:#999">4</span>
			<#if (pageCount > 11)>
				<span style="font-family:Webdings;color:#999">:</span>
			</#if>
		</#if>
	</#if>
	</#if>
	</td>
</tr>
</table>
</#macro>


<#-- 分页信息(员工) -->
<#macro employeesPaging pagingList>
<#local pageCount=pagingList.pageCount><#-- 分页总数-->
<#local rowCount=pagingList.rowCount><#-- 记录总数-->
<#local pageNum=pagingList.pageNum><#--当前页数-->
<#local pageSize=pagingList.pageSize><#--每页记录数-->
<#if rowCount == 0>
	<#if useFlag?exists>
	<div class="pager-top moretopmargin"><span>没有相关记录</span></div>
	<#else>
	<#assign useFlag = 1>
	</#if>
<#else>
    <#if (pageNum !=1)>
      <#if (pageNum != pageCount )>
	         <span>当前显示${((pageNum -1) * pageSize +1)}-${pageNum * pageSize}条/共 ${rowCount} 个员工</span>
	  <#else>
	         <#if ((pageNum -1) * pageSize +1)=(rowCount)>
	              <span>当前显示 第${rowCount}个/ 共${rowCount} 个员工</span>
	         <#else>     
	              <span>当前显示${((pageNum -1) * pageSize +1)}-${rowCount}个/共 ${rowCount}个员工</span>
	         </#if>     
	  </#if>
	<#else>
	  <#if (pageNum != pageCount )>
	         <span>当前显示1-${pageSize}个/共${rowCount} 个员工</span>
	  <#else> 
	         <span>当前显示1-${rowCount}个/共${rowCount} 个员工</span>       
	  </#if>        
	</#if>
	<ol class="pagerpro">
	<#if (pageCount <= 5)>
		<#local startPage = 1>
		<#local endPage = pageCount>
	<#elseif (pageNum + 5 > pageCount)>
		<#local startPage = pageCount - 4>
		<#local endPage = pageCount>
	<#elseif (pageNum - 5 < 1)>
		<#local startPage = 1>
		<#local endPage = 5>
	<#else>
		<#local startPage = pageNum - 5>
		<#local endPage = pageNum + 5>
	</#if>
	<#if (pageCount > 1)>
	  <#if (pageNum != 1)>
	     <li><a class="chn" href="${getPageUrl(1)}" title="第一页">首页</a></li>
	     <li><a class="chn" href="${getPageUrl(pageNum-1)}" title="上页">上一页</a></li>
	  </#if>
	  <#list startPage..endPage as x>
	     <#if x=pageNum>
	        <li class="current"><a href="#">${x}</a></li>
	     <#else>
	        <li><a class="chn" href="${getPageUrl(x)}">${x}</a></li>
	     </#if>
	  </#list>
	  <#if (pageCount != pageNum)>
	     <li><a class="chn" href="${getPageUrl(pageNum+1)}" title="下页">下一页</a></li>
	     <li><a class="chn" href="${getPageUrl(pageCount + 1)}" title="最后一页">尾页</a></li>
	   </#if> 
	</#if>
	</#if>
	</ol>
</#macro>
<#-- 日历控件 -->
<#--
	id : 目标input元素的id（注意，不是name属性，是id属性）
 -->
<#macro cal id format="%Y-%m-%d" text="选择日期">
<#if calcount?exists>
<#assign calcount=calcount+1>
<#else>
<#assign calcount=0>
${importCSS("/components/calendar/skins/aqua/theme.css")}
${importJS("/components/calendar/calendar.js")}
${importJS("/components/calendar/calendar-setup.js")}
${importJS("/components/calendar/lang/calendar-zh-utf8.js")}
</#if>
<img id="calImg${calcount}" src="${base}/components/calendar/skins/aqua/cal.gif" border="0" alt="${text}" style="cursor:pointer">
<script language="JavaScript">Calendar.setup({inputField:"${id}",ifFormat:"${format}",button:"calImg${calcount}"});</script>
</#macro>

<#-- HTML编辑控件 FCKEditor -->
<#macro editor id bar="Default" value="" browser=false upload=true width="80%" height="400px">
<#if editorcount?exists>
<#assign editorcount=editorcount+1>
<#else>
<#assign editorcount=0>
${importJS("/components/fckeditor/fckeditor.js")}
</#if>
<script type="text/javascript">
var oFCKeditor${editorcount} = new FCKeditor("${id}");
oFCKeditor${editorcount}.BasePath = "${base}/components/fckeditor/";
oFCKeditor${editorcount}.Width = "${width}";
oFCKeditor${editorcount}.Height = "${height}";
oFCKeditor${editorcount}.ToolbarSet = "${bar}" ;
<#if browser>
oFCKeditor${editorcount}.Config['LinkBrowser'] = true;
oFCKeditor${editorcount}.Config['ImageBrowser'] = true;
oFCKeditor${editorcount}.Config['FlashBrowser'] = true; 
</#if>
<#if upload>
oFCKeditor${editorcount}.Config['LinkUpload'] = true;
oFCKeditor${editorcount}.Config['ImageUpload'] = true;
oFCKeditor${editorcount}.Config['FlashUpload'] = true;
</#if>
oFCKeditor${editorcount}.Value = "${value?default('')?js_string}";
oFCKeditor${editorcount}.Create();
</script>
</#macro>

<#-- 树形控件 dtree -->
<#--
	两种使用方式：第一种传入nodes，自动生成树，第二种自己写树的内容，形如d.add(...)的形式，注意“d”要与id相同
 -->
<#macro dtree id nodes=[] batch=false useCookies=false target="_self">
<#if dtreecount?exists>
<#assign dtreecount=dtreecount+1>
<#else>
<#assign dtreecount=0>
${importCSS("/components/dtree/dtree.css")}
<script type="text/javascript">var dtreeIconBasePath = "${base}/components/dtree/";</script>
${importJS("/components/dtree/dtree.js")}
</#if>
<div class="dtree">
<#if batch><div align="center"><a href="javascript: ${id}.openAll();">打开</a> | <a href="javascript: ${id}.closeAll();">折叠</a></div></#if>
<script type="text/javascript">
${id} = new dTree('${id}');
${id}.config.target = "${target}";
${id}.config.useCookies = ${useCookies?string};
<#if nodes?has_content>
<#list nodes as node>
${id}.add(<#list node?values as val><#if val_index gt 0>,</#if>'${val?string}'</#list>);
</#list>
<#else>
<#nested>
</#if>
document.write(${id});
</script>
</div>
</#macro>

<#-- 树形控件 tree -->
<#macro tree root="" display="">
<style type="text/css">@import url('components/dtree/dtree.css');</style>
<script type="text/javascript">var dtreeIconBasePath = "components/dtree";</script>
<script language="javascript" src="${base}/components/dtree/dtree.js"></script>
<#nested>
<div class="dtree">
<div style="display:${display};margin-bottom:5px;">菜单控制:【<a href="#" onclick="tree.openAll();this.blur();return false;" style="color:#333333">展开</a>】【<a href="#" onclick="tree.closeAll();this.blur();return false;" style="color:#333333">折叠</a>】</div>
<script type="text/javascript"> 
//建立新树
tree = new dTree('tree');
tree.config.target = "MainFrame";
tree.config.useCookies = false;
var selNum = -1;
var link = "";
//根目录
tree.add(0,-1,'${root}', null, null, null, '${base}/images/tico_root.gif', '${base}/images/tico_root.gif');
var count = 0;
var pLevelIdArray = new Array();
pLevelIdArray[1] = 0;
var currLevel = 1;
for (var i=0; i<treeMenu.length; i++) {
	var item = treeMenu[i];
	var itemLevel = item.level;
	pLevelIdArray[itemLevel+1] = ++count;
	if (item.link!=null && item.link!="") {
		if (item.ico!=null) {
			tree.add(count, pLevelIdArray[itemLevel], item.name, item.link, null, null, item.ico, item.ico);
		} else {
			tree.add(count, pLevelIdArray[itemLevel], item.name, item.link);
		}
	} else {
		if (item.ico!=null) {
			tree.add(count, pLevelIdArray[itemLevel], item.name, null, null, null, item.ico, item.ico);
		} else {
			tree.add(count, pLevelIdArray[itemLevel], item.name);
		}
	}
	if (item.select) {
		selNum = count;
		link = item.link;
	}
}
document.write(tree);
tree.openAll();
if (selNum != -1) {
	tree.openTo(selNum,true);
	top.document.frames["MainFrame"].location.href=link;
}
</script>
</div>
</#macro>

<#-- 缓存页面执行结果-通过时间 -->
<#macro cacheByTime key time refresh=false>
<#if cacheByTimeCount?exists>
<#assign cacheByTimeCount=cacheByTimeCount+1>
<#else>
<#assign cacheByTimeCount=0>
<#assign oscache=JspTaglibs["/WEB-INF/oscache.tld"]>
</#if>
<@oscache.cache key=key time=time refresh=refresh>
<#nested>
</@oscache.cache>
</#macro>

<#-- 缓存页面执行结果-通过写文件 -->
<#macro cacheByFile path file parse=false>
<#attempt>
<#include "${@neo.core.Constants@CACHE_BASE_PATH}${path}/${file}" parse=parse>
<#recover>
<#assign _CACHE_CONTENT_>
<#nested>
</#assign>
${@neo.core.util.FileUtil@addFileCache(path,file,_CACHE_CONTENT_)}
${_CACHE_CONTENT_}
</#attempt>
</#macro>

<#-- 中转页 -->
<#macro redir url="">
<#if url?has_content>
<script language="JavaScript">
<!--
location.replace("${url}");
//-->
</script>
<#else>
<div style="font-family:Tahoma;font-size:12px;line-height:150%">当前页面 <span style="color:#FF0000">${request.servletPath}</span> 仅作为中转页，不要在本页写具体业务内容。<br>请修改页面中 <b>url</b> 变量到要转向的地址。<br>例如：&lt;@p.redir url="<span style="color:red">xxx_list.ftl</span>" /&gt;</div>
</#if>
</#macro>

<#-- 格式化时间，参数是秒 -->
<#macro formatTime second>
<#local hour = (second / 3600)?int>
<#local min = ((second % 3600) / 60)?int>
<#local sec = second % 60>
<#if second==0>0<#else><#if hour==0 && min==0>不足 1 分钟<#else><#if hour!=0>${hour} 小时 </#if><#if min!=0>${min} 分钟</#if></#if></#if>
</#macro>